#ifndef __CTS_H__
#define __CTS_H__
#include <stdio.h>
#include <string.h>
#include <iostream>

#define TS_SIZE 188
/*this class holds the TS data.Also parse the TS header and determine the
header size based on the header field (adaptation_field_control field)
*/
class CTS{

public:
	/**
	c'tor
	@param chArray- a pointer to the TS data. it will be copied by the c'tor to the class's data array (m_data)
	*/
	CTS(const char* chArray);
	/**
	d'tor
	*/
	~CTS(void);
	/**
	@return pointer to the TS payload
	*/
	const char* getPayload();
	/**
	@return the TS header's length
	*/
	unsigned int getHeaderLength();
	/**
	@return the TS payload length
	*/
	unsigned int getPayloadLength();
	/**
	@return the adaptation_field_control field of the TS
	*/
	unsigned int getAdaptationFieldControl();
	/**
	@return the payload_unit_start_indicator field of the TS
	*/
	unsigned int getPayloadStartIndicator();
	/**
	@return the PID field of the TS
	*/
	unsigned int getPID();
	/**
	@return the continuty_counter field of the TS
	*/
	unsigned int getContinuityCounter();
	/**
	@return the program_clock_reference_base field of the TS
	*/
	unsigned long long getPCR();
	/**
	@param ContinuityCounter-  the ContinuityCounter of the new TS. 
	@return 1 if the Continuity is maintained by the new TS ContinuityCounter ,0 otherwise
	*/
	bool isNextTo(int ContinuityCounter);
	/**
	@return pointer to the payload of the TS
	*/
	char* getData();
private:
	/**
	parses the TS's header in order to determine its header size and retrieve its important fields .
	*/
	void _parseTsHeader();

	char m_data[188];
	unsigned int m_continuity_counter;
	unsigned int m_PID;
	unsigned int m_payload_unit_start_indicator;
	unsigned int m_adaptation_field_control;
	bool m_PCR_flag;
	unsigned long long m_program_clock_reference_base;//PCR
	int m_headerLength;
};
#endif //__CTS_H__
